#include <string>
using std::string;
#include "NetDefs.h"
#include "SyncWrapper.h"
#include <iostream>
using std::cout;
using std::endl;

#include "ParkinglotDB.h"
void Parser(string s,SyncWrapper* sw,Socket* mysock )
{
	char *c=new char[s.size()+1];
	strcpy(c,s.c_str());
	c[s.size()] ='\0';
	char *tmp;
	tmp=strtok(c," ");
	if(strcmp(tmp,"topcam:")==0)
	{
		tmp=strtok(NULL," ");
		if(strcmp(tmp,"carentered")==0)
		{
			sw->CarEnteredUpperCam(atoi(strtok(NULL," \n")));
		}
		if(strcmp(tmp,"carexited")==0)
		{
			sw->CarExits(atoi(strtok(NULL," \n")));
		}
		if(strcmp(tmp,"carunparked")==0)
		{
			int x=atoi(strtok(NULL," \n"));
			int y=atoi(strtok(NULL," \n"));
			sw->CarUnparked(x,y);
		}
		if(strcmp(tmp,"carparked")==0)
		{
			int id=atoi(strtok(NULL," \n"));
			int x=atoi(strtok(NULL," \n"));
			int y=atoi(strtok(NULL," \n"));
			sw->CarParked(id,x,y);
		}
		if(strcmp(tmp,"video")==0)
		{
			int id = atoi(strtok(NULL," \n"));
			string video = strtok(NULL," \n");
			sw->addVideo(id,video);
		}
	}
	if(strcmp(tmp,"frontcam:")==0)
	{
		tmp=strtok(NULL," ");
		if(strcmp(tmp,"carentered")==0)
		{
			sw->CarEnteredGroundCam (atoi(strtok(NULL," \n")));
		}
	}
	if(strcmp(tmp,"ui:")==0)
	{
		tmp=strtok(NULL," \n");
		if(strcmp(tmp,"cardatarequest")==0)
		{
			sw->getCarInfo(atoi(strtok(NULL," \n")),mysock);
		}
		if(strcmp(tmp,"plotdreq")==0)
		{
			sw->getParkingLotInfo(mysock);
		}
	}
	delete c;
}